<template>
  <div>
	<a-spin :spinning="isLoading">
		<div class="xy-logo"><img src="~@/assets/images/xylogo.png"/></div>
		<div class="banner">
			<img src="~@/assets/images/banner.jpg"/>
		</div>

		<nav class="xy-in-nav">
			<router-link to="/sign">
				<img src="~@/assets/images/icon4.png"/>
				<p>考试报名</p>
			</router-link>
			<router-link to="/grading">
				<img src="~@/assets/images/icon6.png"/>
				<p>成绩查询</p>
			</router-link>
			<router-link to="/cert">
				<img src="~@/assets/images/icon5.png"/>
				<p>证书下载</p>
			</router-link>
		</nav>
		<!---->
		<div class="xy-in-newsbox">
			<div class="title">
			<div class="title_a"><span></span>考级<em>资讯</em></div>
			</div>
			<div class="xy-in-newstop"><router-link  to="/notice?id=10001"><img src="~@/assets/images/ig3.png"/></router-link></div>
			<ul class="xy-in-newsul">
				<li v-for="(item,i) in newsList" :key="i"><router-link  :to="`/info?id=${item.article_id}`">{{item.title}}</router-link></li>
			</ul>
		</div>
		<!---->                                                                    
	</a-spin>
	
  </div>
 
</template>

<script>
import {onBeforeRouteLeave} from 'vue-router';
import storage from 'store'
import store from '@/store'
import {detail} from '@/api/user/index';
import {list} from '@/api/news/index'
import { Modal } from 'ant-design-vue';
import { ExclamationCircleOutlined } from '@ant-design/icons-vue';
import { createVNode } from 'vue';
export default {
  name: 'Index',
  data(){
	return{
      isLoading: false,// 正在加载
	  newsList:[]
	}
  },
  created () {
    this.getNewsList();
  },
  methods: {
	getNewsList () {
		list().then((res)=>{
			this.newsList = res.data.list.data ;
		})
    },
  },
  //离开页面检验
//   mounted(){
// 	onBeforeRouteLeave((to,from,next)=>{
// 		if(to.path!='/sign') {next();return;};
// 		//校验是否登录
// 		if (!storage.get('Access-Token')){next();return;}
		
// 		//校验考级卡
// 		detail().then(res=>{
// 			let user = res.data.userInfo;
// 			if(!user.avatar_id){
// 				this.$message.error('请先完善资料后报名！');
// 				next({ path: '/profile' })
// 				return;
// 			}
// 			if(user.grade_code){
// 				next();return;
// 			}
// 			Modal.confirm({
// 				title: '温馨提示',
// 				icon: createVNode(ExclamationCircleOutlined),
// 				content: createVNode('div', { style: 'color:red;' }, '您还未绑定考级卡，现在申请？'),
// 				okText:'确定',
// 				cancelText:'取消',
// 				onOk() {
// 					next({ path: '/code' })
// 				},
// 				onCancel() {},
// 				class: 'test',
// 			});					
// 		})
		
// 	})
//   },
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.ant-spin-nested-loading{background: url(~@/assets/images/bgd.jpg) top center/100% auto no-repeat #f3f0e9;}
</style>
